﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.Entities;
using Model.Helpers;
using Model.Entities.Ranking;
using System.ComponentModel.DataAnnotations;

namespace Model.Account
{
    public class User
    {
        [Key]
        public long UserID { get; set; }

        [Required]
        public Guid MembershipID { get; set; }

        [Required]
        [StringLength(20)]
        public string UserName { get; set; }

        [Required]
        [StringLength(50)]
        public String Name { get; set; }

        [Required]
        [StringLength(50)]
        public String LastName { get; set; }

        public FacebookUser FacebookUser { get; set; }
        public Ranking Ranking { get; set; }
        public ICollection<UserVehicle> UserVehicles { get; set; }
        public ICollection<Publication> Publications { get; set; }
        public ICollection<Image> Images { get; set; }

        #region Methods

        public bool HasVehicle(int vehicleID)
        { 
            var exists = from uv in this.UserVehicles
                         where uv.UserVehicleID == vehicleID
                         select uv;
            return (exists != null && exists.Count() != 0);
        }

        #endregion

    }
}
